import request from '@/utils/request';

/**
 * 获取商品列表
 * @returns {Promise<any>}
 */
export async function getGoods(params) {
  return request( '/admin/goods', { params } )
}


/**
 * 上架和下架商品
 * @param goodId  商品id 
 * @returns {Promise<any>}
 */
export async function isOn(goodId) {
  return request.patch(`/admin/goods/${goodId}/on`)
}


/**
 * 推荐和不推荐商品
 * @param goodId  商品id 
 * @returns {Promise<any>}
 */
 export async function isRecommend(goodId) {
  return request.patch(`/admin/goods/${goodId}/recommend`)
}


/**
 * 添加商品
 * @param {*} params 
 */
export async function addGoods(data) {
  return request.post('/admin/goods', { data })
}


/**
 * 商品详情
 * @param {*} params 
 */
 export async function showGoods(editId) {
  return request.get(`/admin/goods/${editId}?include=category`)
}



/**
 * 修改商品信息
 * @param {*} params 
 */
 export async function updateGoods(editId, data) {
  return request.put(`/admin/goods/${editId}`, { data })
}









